package com.study.ju.service.impl.concurrenceDbTest;

import com.study.ju.dao.concurrenceDbTest.ProductMapper;
import com.study.ju.entity.Product;
import com.study.ju.service.concurrenceDbTest.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by tao on 2018/8/5.
 */
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public void buyProduct(final Product product) {
        System.out.println("buyProduct:" +Thread.currentThread().getName()+ "::"+product.getBuyNum());
        productMapper.updateProduct(product);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
